<template>
	<view class="title">
		<up-navbar title="我的钱包"
			bgColor="rgba(0,0,0,0)"
			:autoBack="true"
			:placeholder="true"
			:fixed="false"
			titleStyle="color: #000000"></up-navbar>

		<view class="money">
			<view>总金额（元）</view>
			<view>¥{{userinfo.balance}}</view>
			<!-- <view class="money-data">
				<view>
					<text>可提现金额</text>
					<text>¥2093.00</text>
				</view>
				<view>
					<text>审批中金额</text>
					<text>¥3190.00</text>
				</view>
			</view> -->

			<view class="title-btn">
				<view @click="$path.navigateTo('./transfer')">转账</view>
				<view @click="$path.navigateTo('./withdraw')">立即提现</view>
			</view>
		</view>
	</view>

	<view class="info">
		<view class="tit">
			<text>查看明细</text>
			<view class="" @click="$path.navigateTo('./detail')">
				<text>查看更多</text>
				<up-icon name="arrow-right" color="#BABABA" size="15"></up-icon>
			</view>
		</view>

		<view class="info-item"
			v-for="(item,index) in list">
			<view>
				<view>{{item.title}}</view>
				<view>{{timeFormat(item.created_at, 'yyyy-mm-dd hh:MM:ss')}}</view>
			</view>
			<view class="red">{{item.nums.slice(0,1)== '-'? item.nums: `+${item.nums}`}}</view>
		</view>

		<view class="tips">
			全部明细已获取~~
		</view>
	</view>
</template>

<script setup>
	import { timeFormat } from '@/uni_modules/uview-plus';
	import { onShow, onReachBottom } from '@dcloudio/uni-app'
	import api from '../../api/api';
	import { useCounterStore } from '/stores/user';
	import { storeToRefs } from 'pinia'
	import { reactive, ref } from 'vue';
	const use = useCounterStore()
	const { userinfo } = storeToRefs(use)

	onShow(() => {
		bills()
	})

	const list = reactive([])

	function bills(type = false) {
		api.user.bills().then(res => {
			Object.assign(list, res.data.list_data)
		})
	}

	// const page = ref(1)
	// onReachBottom((e) => {
	// 	page.value++
	// 	bills(true)
	// })
</script>

<style lang="scss">
	.title {
		width: 750rpx;
		position: relative;
		padding: 32rpx;
		padding-top: 0;
		background-image: linear-gradient(180deg, #FFDFB8 54%, #e3f7ff00 100%);

		.money {
			width: 686rpx;
			// height: 498rpx;
			background: #FFFFFF;
			border-radius: 12rpx;
			font-weight: 400;
			font-size: 24rpx;
			color: #BEBEBE;
			padding: 32rpx;
			margin-top: 32rpx;

			>view:nth-child(2) {
				color: #333333;
				font-size: 48rpx;
				font-weight: 600;
				margin-top: 32rpx;
			}

			.money-data {
				display: flex;
				justify-content: space-between;
				margin-top: 72rpx;

				>view {
					display: flex;
					align-items: center;
					flex-direction: column;
					font-weight: 500;
					font-size: 28rpx;
					color: #BEBEBE;

					>text:nth-child(2) {
						font-weight: 600;
						font-size: 32rpx;
						color: #333333;
						margin-top: 20rpx;
					}
				}
			}

			.title-btn {
				display: flex;
				justify-content: space-between;
				margin-top: 52rpx;

				view {
					width: 200rpx;
					height: 80rpx;
					line-height: 80rpx;
					text-align: center;
					width: 280rpx;
					height: 80rpx;
					background: #F6941D;
					box-shadow: 0 4rpx 8rpx 0 #0000001a;
					border-radius: 40rpx;
					font-weight: 600;
					font-size: 32rpx;
					color: #ffffff;
				}

				>view:nth-child(1) {
					border: 2rpx solid #F6941D;
					background: none;
					color: #F6941D;
				}
			}
		}
	}

	.info {
		padding: 32rpx;
		padding-top: 0;

		.tit {
			font-weight: 600;
			font-size: 32rpx;
			color: #333333;
			margin-bottom: 30rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			>view:nth-of-type(1) {
				font-weight: 400;
				font-size: 24rpx;
				color: #999999;
				display: flex;
				align-items: center;
			}
		}

		.info-item {
			padding: 0 32rpx;
			height: 150rpx;
			border-bottom: 2rpx solid #d9d9d9;
			display: flex;
			justify-content: space-between;
			align-items: center;

			>view:nth-child(1) {
				font-weight: 500;
				font-size: 28rpx;
				color: #333333;

				>view:nth-child(2) {
					font-weight: 400;
					font-size: 24rpx;
					color: #9A9A9A;
					margin-top: 24rpx;
				}
			}

			.red {
				font-weight: 600;
				font-size: 28rpx;
				color: #FF345E;
			}

			.green {
				font-weight: 600;
				font-size: 28rpx;
				color: #489C6F;
			}
		}

		.tips {
			margin-top: 32rpx;
			text-align: center;
			width: 100%;
			font-size: 26rpx;
			color: #c1c1c1;
		}
	}
</style>